﻿package kit4j.view.cs.swing.panel;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.LayoutManager;

import javax.swing.JPanel;

import kit4j.view.cs.component.BackgroundConstraints;
import kit4j.view.cs.component.FullComponent;
import kit4j.view.cs.component.FullComponentHelper;

/**
 * 实现了FullComponent接口的继承自JPanel的类型。
 * 
 * @author MiniKnife
 * 
 */
public class JFullPanel extends JPanel implements FullComponent {

	private static final long serialVersionUID = 1L;

	public JFullPanel() {
		super();
	}

	public JFullPanel(LayoutManager layout) {
		super(layout);
	}

	public JFullPanel(boolean isDoubleBuffered) {
		super(isDoubleBuffered);
	}

	public JFullPanel(LayoutManager layout, boolean isDoubleBuffered) {
		super(layout, isDoubleBuffered);
	}

	private FullComponentHelper fullComponentHelper = new FullComponentHelper(this);

	@Override
	public void setBackgroundImage(Image img) {
		this.fullComponentHelper.setBackgroundImage(img);
	}

	@Override
	public Image getBackgroundImage() {
		return this.fullComponentHelper.getBackgroundImage();
	}

	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);

		this.fullComponentHelper.paintBackgroundImage(g);
	}
	
	@Override
	public BackgroundConstraints getBackgroundConstraints() {
		return this.fullComponentHelper.getBackgroundConstraints();
	}

	@Override
	public void setBackgroundConstraints(BackgroundConstraints bgc) {
		this.fullComponentHelper.setBackgroundConstraints(bgc);
	}

	@Override
	public void setAutoGenerateComponentsBackgroundImage(boolean autoGenerateComponentsBackgroundImage) {
		this.fullComponentHelper.setAutoGenerateComponentsBackgroundImage(autoGenerateComponentsBackgroundImage);
	}

	@Override
	public boolean isAutoGenerateComponentsBackgroundImage() {
		return this.fullComponentHelper.isAutoGenerateComponentsBackgroundImage();
	}
	
	@Override
	public void validate() {
		this.fullComponentHelper.updateComponentsBackgroundImage();
		
		super.validate();
	}

}
